package com.mdd.front.controller.subject;

import com.mdd.common.core.AjaxResult;
import com.mdd.common.core.PageResult;
import com.mdd.common.validator.annotation.IDMust;
import com.mdd.front.service.subject.ISubjectService;
import com.mdd.front.validate.PageParam;
import com.mdd.front.vo.subject.SubjectDetailVo;
import com.mdd.front.vo.subject.SubjectListVo;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 专题专区管理
 * @author panweiliang
 */
@RestController
@RequestMapping("/api/subject")
public class SubjectController {

    @Resource
    ISubjectService iSubjectService;


    /**
     * 专题专区列表
     *
     * @author panweiliang
     * @param pageParam 分页参数
     * @param params 搜索参数
     * @return Object
     */
    @GetMapping("/list")
    public Object list(@Validated PageParam pageParam,
                       @RequestParam Map<String, String> params) {
        PageResult<SubjectListVo> list = iSubjectService.list(pageParam, params);
        return AjaxResult.success(list);
    }

    /**
     * 专题专区详情
     *
     * @author panweiliang
     * @param id 主键ID
     * @return Object
     */
    @GetMapping("/detail")
    public Object detail(@Validated @IDMust() @RequestParam("id") Integer id) {
        SubjectDetailVo detail = iSubjectService.detail(id);
        return AjaxResult.success(detail);
    }


}
